package com.gitee.openviducn.inspector.enums;

import lombok.Getter;

import java.util.Objects;

/**
 *
 * 相关参考文档：<br>
 * <a href="http://openvidu_cn.gitee.io/openvidu_docs_cn/docs/reference-docs/openvidu-server-webhook/">
 *  OpenVidu Server Webhook
 * </a>
 *
 * @Author: https://gitee.com/wesleyOne
 * @Date: 02.29 2020
 */
@Getter
public enum  CDREventEnum {

    /**
     *
     */
    SESSION_CREATED("sessionCreated", "会话创建"),
    SESSION_DESTROYED("sessionDestroyed", "会话销毁"),
    PARTICIPANT_JOINED("participantJoined", "参与者加入"),
    PARTICIPANT_LEFT("participantLeft", "参与者退出"),
    WEBRTC_CONNECTION_CREATED("webrtcConnectionCreated", "webrtc连接创建"),
    WEBRTC_CONNECTION_DESTROYED("webrtcConnectionDestroyed", "webrtc连接销毁"),
    RECORDING_STATUE_CHANGED("recordingStatusChanged", "录制状态变化"),
    FILTER_EVENT_DISPATCHED("filterEventDispatched", "调用过滤器"),
    ;

    private String code;
    private String desc;
    CDREventEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static CDREventEnum getByCode(String code) {
        for (CDREventEnum em : CDREventEnum.values()) {
            if (Objects.equals(code, em.getCode())) {
                return em;
            }
        }
        return null;
    }
}
